<template>
  <div class="app-container">
    <el-form ref="form" :model="ItripHotel" label-width="120px">
      <el-form-item label="酒店名称">
        <el-input v-model="ItripHotel.hotelName" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="edit">Edit</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data: function () {
    return {
      ItripHotel: {},
    };
  },
  mounted() {
    //加载时回填酒店信息
    this.getInfo();
  },
  methods: {
    //获取酒店信息
    getInfo() {
      var paramId = this.$route.params.id;
      console.log(paramId);
      this.axios({
        url: "http://localhost:8081/hotel/itrip-hotel/selectById",
        method: "get",
        params: { id: paramId },
      }).then((res) => {
        this.ItripHotel = res.data.data.itripHotel;
      });
    },
    //修改请求
    edit() {
      var paramId = this.$route.params.id;
      this.axios({
        url: "http://localhost:8081/hotel/itrip-hotel/updateHotel",
        method: "post",
        data: JSON.stringify(this.ItripHotel),
        //params:JSON.stringify(this.ItripHotel),
        // params:{
        //   //  id:paramId,
        //   //  hotelName:this.ItripHotel.hotelName,
        //   //  countryId:this.ItripHotel.countryId,
        //   //  provinceId:this.ItripHotel.provinceId,
        //   //  cityId:this.ItripHotel.cityId,
        //   //  address:this.ItripHotel.address,

        // },
        headers: {
          "Content-Type": "application/json",
        },
      }).then((res) => {
        // console.log("******"+JSON.stringify(res))
        console.log(res.data.code)
        if (res.data.code == 200) {
         //跳转页面
           this.$message({
          message: '修改成功',
          type: 'success'
          });
          this.$router.push("/hotel/hotelList")
        }
      });
    },
  },
};
</script>

<style>
</style>